<?php

/**
 * This is the model class for table "account_tracking".
 *
 * The followings are the available columns in table 'account_tracking':
 * @property integer $account_id
 * @property string $tracking_date
 * @property double $money_before
 * @property double $money_after
 * @property integer $click_num
 * @property integer $ad_status
 * @property integer $grid_status
 * @property integer $login_status
 * @property string $mac_address
 */
class AccountTracking extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AccountTracking the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'account_tracking';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('account_id', 'required'),
			array('account_id, click_num, ad_status, grid_status, login_status', 'numerical', 'integerOnly'=>true),
			array('money_before, money_after', 'numerical'),
			array('mac_address', 'length', 'max'=>255),
			array('tracking_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('account_id, tracking_date, money_before, money_after, click_num, ad_status, grid_status, login_status, mac_address', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'account_id' => 'Account',
			'tracking_date' => 'Tracking Date',
			'money_before' => 'Money Before',
			'money_after' => 'Money After',
			'click_num' => 'Click Num',
			'ad_status' => 'Ad Status',
			'grid_status' => 'Grid Status',
			'login_status' => 'Login Status',
			'mac_address' => 'Mac Address',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('account_id',$this->account_id);
		$criteria->compare('tracking_date',$this->tracking_date,true);
		$criteria->compare('money_before',$this->money_before);
		$criteria->compare('money_after',$this->money_after);
		$criteria->compare('click_num',$this->click_num);
		$criteria->compare('ad_status',$this->ad_status);
		$criteria->compare('grid_status',$this->grid_status);
		$criteria->compare('login_status',$this->login_status);
		$criteria->compare('mac_address',$this->mac_address,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}